package FSMDemo.entity.mine
{
	import FSMDemo.entity.mine.params.MineParams;
	
	import com.cheezeworld.entity.Entity;

	public class Mine extends Entity
	{
		
		public function get remainingMinerals() : Number
		{
			return m_remainingMinerals;
		}
		
		public function Mine(a_params:MineParams)
		{
			super(a_params);
			
			m_remainingMinerals = a_params.startingMinerals;
		}
		
		public override function update(a_timePassed:int):void
		{
			super.update( a_timePassed );				
		}
		
		// deducts the amount of minerals harvested, and returns how much is taken
		public function harvest( a_amount:Number ) : Number
		{
			m_remainingMinerals -= a_amount;
			if( remainingMinerals < 0 )
			{
				var defecit:Number = remainingMinerals;
				m_remainingMinerals = 0;
				return a_amount + defecit;				
			}
			else
			{
				return a_amount;
			}
		}
		
		private var m_remainingMinerals:Number;
		
	}
}


